package gui;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;


public class GUImain extends JFrame {
	


	JButton	button_newGiroAccount;
	JButton	button_newDepositeAccount;
	JButton button_accountStatement;
	JButton button_transfer;
	JButton button_addMoney;
	


	public GUImain() {
		
		

		
		this.getContentPane().setLayout(null);

		this.frontWindow();

		this.addWindowListener(new WindowListener() {

			public void windowClosed(WindowEvent arg0) {
			}

			public void windowActivated(WindowEvent e) {
			}

			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
			
			public void windowDeactivated(WindowEvent e) {
			}

			public void windowDeiconified(WindowEvent e) {
			}

			public void windowIconified(WindowEvent e) {
			}

			public void windowOpened(WindowEvent e) {
			}

			

		});

	}

	public void frontWindow() 
	{

		button_newDepositeAccount = new JButton("create Deposite Account");
		button_newGiroAccount = new JButton("create Giro Account");
		button_addMoney = new JButton("add Money");
		button_transfer = new JButton("transfer Money");
		button_accountStatement = new JButton("Account Value");

		button_newDepositeAccount.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent arg0) {
				try {
					newDepositeAccount();
				} catch (Exception e) {
					e.printStackTrace();
				}
				
			}

		});
		
		button_newGiroAccount.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				try {
					newGiroAccount();
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				
			}
		});
		
		button_addMoney.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				addMoney();
				
			}
		});
		
		button_transfer.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				transferMoney();
				
			}
		});
		button_accountStatement.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				accountStatement();
			}
		});

		// position

		button_newDepositeAccount.setBounds(10, 280, 220, 30);
		button_newGiroAccount.setBounds(240, 280, 220, 30);
		button_addMoney.setBounds(10, 20, 220, 30);
		button_transfer.setBounds(10, 70, 220, 30);
		button_accountStatement.setBounds(10, 130, 220, 30);
		
		// add elements
		this.getContentPane().add(button_newDepositeAccount);
		this.getContentPane().add(button_newGiroAccount);
		this.getContentPane().add(button_addMoney);
		this.getContentPane().add(button_transfer);
		this.getContentPane().add(button_accountStatement);
		
		this.pack();
	}
	
	
	public void newDepositeAccount() throws Exception{
		GUInewDepositeAccount guiDepositeWindow = new GUInewDepositeAccount();
		guiDepositeWindow.setBounds(10, 10, 400, 400);
		guiDepositeWindow.setVisible(true);
		
	}
	
	public void newGiroAccount() throws Exception{
		GUInewGiroAccount guiGiroWindow = new GUInewGiroAccount();
		guiGiroWindow.setBounds(10, 10, 400, 400);
		guiGiroWindow.setVisible(true);
		
	}
	
	public void addMoney(){
		GUIaddMoney addMoney = new GUIaddMoney();
		addMoney.setBounds(10, 10, 400, 400);
		addMoney.setVisible(true);
	}
	
	public void transferMoney(){
		GUItransferMoney transferMoney = new GUItransferMoney();
		transferMoney.setBounds(10, 10, 400, 400);
		transferMoney.setVisible(true);
	}
	
	public void accountStatement(){
		GUIaccountStatement accountStatement = new GUIaccountStatement();
		accountStatement.setBounds(10, 10, 500, 400);
		accountStatement.setVisible(true);
	}
	
}
